package com.ljh.jxc.modules.suo.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ljh.jxc.modules.suo.entity.Quotation;
import com.ljh.jxc.service.QuotationService;
import com.ljh.jxc.common.utils.PageUtils;
import com.ljh.jxc.common.utils.R;



/**
 * 报价单
 *
 * @author liujinghui
 * @email liujinghui@163.com
 * @date 2021-12-01 13:49:03
 */
@RestController
@RequestMapping("jxc/quotation")
public class QuotationController {
    @Autowired
    private QuotationService quotationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("jxc:quotation:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = quotationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{quotationId}")
    @RequiresPermissions("jxc:quotation:info")
    public R info(@PathVariable("quotationId") String quotationId){
		Quotation quotation = quotationService.getById(quotationId);

        return R.ok().put("quotation", quotation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("jxc:quotation:save")
    public R save(@RequestBody Quotation quotation){
		quotationService.save(quotation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("jxc:quotation:update")
    public R update(@RequestBody Quotation quotation){
		quotationService.updateById(quotation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("jxc:quotation:delete")
    public R delete(@RequestBody String[] quotationIds){
		quotationService.removeByIds(Arrays.asList(quotationIds));

        return R.ok();
    }

}
